<?php

namespace App\Http\Requests\Admin\V1;

class PermissionStoreRequest extends FormRequest
{
    /**
     * @expalin 验证规则
     * @return \string[][]
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/4/1/10:17
     */
    public function rules()
    {
        return [
            'parent_id' => ['bail', 'required', 'integer'],
            'name'      => ['bail', 'required', 'max:50', 'unique:permissions,name'],
            'title'     => ['bail', 'required', 'max:20'],
            'is_enable' => ['bail', 'required', 'boolean'],
        ];
    }

    /**
     * @expalin 自定义错误
     * @return array
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/4/1/10:17
     */
    public function messages()
    {
        return [
            'parent_id.required' => trans('admin/v1/request.permission.parent_id-required'),
            'parent_id.integer'  => trans('admin/v1/request.permission.parent_id-integer'),
            'name.required'      => trans('admin/v1/request.permission.name-required'),
            'name.max'           => trans('admin/v1/request.permission.name-max'),
            'name.unique'        => trans('admin/v1/request.permission.name-unique'),
            'title.required'     => trans('admin/v1/request.permission.title-required'),
            'title.max'          => trans('admin/v1/request.permission.title-max'),
            'is_enable.required' => trans('admin/v1/request.permission.is_enable-required'),
            'is_enable.boolean'  => trans('admin/v1/request.permission.is_enable-boolean'),
        ];
    }
}
